package com.example.util;

import com.example.inter.LoginInfo;
import com.example.inter.LoginCallBack;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;

/**
 * Created by Administrator on 2016/2/29.
 */
public class LoginStudent implements LoginInfo {
   /**
    * Login @getLogininfo
    * */
    @Override
    public void getLoginInfo(String email, String password, final LoginCallBack loginCallBack) {
        RequestParams params = new RequestParams();
        params.addBodyParameter("StudentNumber",email);
        params.addBodyParameter("StudentPassword",password);
        HttpUtils utils = new HttpUtils();
        utils.send(HttpRequest.HttpMethod.POST,
                "http://192.168.191.1/app/index.php/student/login", params,
                new RequestCallBack<String>() {
                    @Override
                    public void onLoading(long total, long current, boolean isUploading) {

                    }

                    @Override
                    public void onSuccess(ResponseInfo<String> responseInfo) {

                        loginCallBack.onSuccess(responseInfo.result);
                    }

                    @Override
                    public void onStart() {
                    }

                    @Override
                    public void onFailure(HttpException error, String msg) {
                        //// TODO: 2015/12/18  ∂
                        loginCallBack.onFailed();
                    }
                });
    }
}


